/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.fd.service;

import java.io.IOException;
import java.io.InputStream;
import java.util.*;

import com.xy.biz.fd.domain.req.GetPdfRequest;
import com.xy.biz.fd.domain.req.PrintQrCodeRequest;
import com.xy.biz.fd.domain.req.document.CopyDocumentRequest;
import com.xy.biz.fd.domain.req.document.GetDocumentChangeRequest;
import com.xy.biz.fd.domain.req.document.GetDocumentRequest;
import com.xy.biz.fd.domain.resp.GetDocumentResponse;
import com.xy.biz.fd.domain.resp.GetEditorInfoResponse;
import com.xy.biz.fd.domain.bo.DocumentBO;
import com.xy.biz.fd.domain.query.DocumentQuery;
import com.xy.biz.fd.domain.resp.ListDocumentModifyInfoResponse;
import com.xy.lang.domain.Result;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 *
 * @author wwj
 * @date 2021-2-1
 */
public interface DocumentService {

    /**
     * 保存
     *
     * @param documentBO
     */
    Result<? extends GetDocumentResponse> saveDocument(DocumentBO documentBO);

    /**
     * 保存多个
     *
     * @param collection
     */
    Result<?> saveAllDocument(Collection<DocumentBO> collection);

    /**
     * 更新文件名
     *
     * @param documentBO
     */
    Result<? extends Integer> updateDocument(DocumentBO documentBO);
    Result<?> updateAllDocument(Collection<DocumentBO> collection);
    Result<? extends Integer> replaceDocument(MultipartHttpServletRequest request);

    /**
     * 根据id更新文件
     *
     * @param query
     */
    Result<? extends Integer> updateDocumentById(DocumentQuery query);

    /**
     * 更新（移动文件）
     *
     * @param documentBO
     */
    Result<?> updateMoveDocument(DocumentBO documentBO);

    /**
     * 删除
     *
     * @param documentId
     */
    Result<?> deleteDocument(Long documentId);

    /**
     * 批量删除
     *
     * @param request
     */
    Result<?> deleteDocumentByIds(GetDocumentChangeRequest request);

    /**
     * 查找一个
     *
     * @param documentId
     * @return
     */
    DocumentBO getDocument(Long documentId);


    GetEditorInfoResponse getDocumentByDocument(GetDocumentRequest documentId);

    /**
     * 查找多个
     *
     * @param collection 标识集合
     */
    List<DocumentBO> listDocumentById(Collection<Long> collection);

    /**
     * 查找多个
     *
     * @param query 查找条件
     */
    List<DocumentBO> listDocument(DocumentQuery query);

    /**
     * 统计个数
     *
     * @param query 查找条件
     */
    int countDocument(DocumentQuery query);

    GetDocumentResponse createDocument(DocumentBO documentBO);

    /**
     * 恢复文档
     * @param documentId
     * @return
     */
    Result<?> recoverDocument(Long documentId);

    /**
     * 批量恢复
     *
     * @param request
     */
    Result<?> recoverDocumentByIds(GetDocumentChangeRequest request);

    /**
     * 上传文档
     * @param request
     * @return
     */
    Result<Object> uploadDocument(MultipartHttpServletRequest request);

    /**
     * 复制文档
     * @param request
     * @return
     */
    Result<GetDocumentResponse> copyDocument(CopyDocumentRequest request);

    GetDocumentResponse getDocumentInfoByDocumentId(Long documentId);

    /**
     * 获得文档变更历史信息
     * @param documentId
     * @return
     */
    Result<List<ListDocumentModifyInfoResponse>> listDocumentMotifyInfoByDocumentId(Long documentId);

    /**
     * 根据(文件名、文件编码、文件夹名)模糊查找文件和文件夹
     * @param keyword
     * @return documentBO
     */
    List<Object> listDocumentByDocumentName(String keyword);

    /**
     * 批量彻底删除
     *
     * @param request
     */
    Result<?> realDelete(GetDocumentChangeRequest request);

    Result<?> downloadFile(Long documentId);

    void getDocumentByPdf(Long documentId, HttpServletResponse response);

    /**
     * 打印二维码表格
     *
     * @param request 标识集合
     */
    Result<?> printForm(PrintQrCodeRequest request) throws IOException;
}
